package csp;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class CSP2013123 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = Integer.parseInt(scanner.nextLine());
        List<Integer> list = Arrays.stream(scanner.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());
        int min = list.stream().min(Comparator.comparingInt(o -> o)).get();
        int max = list.stream().max(Comparator.comparingInt(o -> o)).get();
        int size = 0;
        for (int i = min; i <= max; i++) {
            int current = getMaxCount(i, list);
            size = Math.max(size, i * current);
        }
        System.out.println(size);
    }

    private static int getMaxCount(int key, List<Integer> list) {
        int start = 0;
        boolean flag = false;
        int maxCount = 0;
        for (int i = 0; i < list.size(); i++) {
            int current = list.get(i);
            if (current >= key && !flag) {
                flag = true;
                start = i;
            } else if (current < key && flag) {
                flag = false;
                maxCount = Math.max(i - start, maxCount);
            }
        }
        if (flag) {
            maxCount = Math.max(list.size() - start, maxCount);
        }
        return maxCount;
    }
}
